package cn.gson.springboot.controller;

import cn.gson.springboot.model.pojos.Warehouse;
import cn.gson.springboot.model.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class WarehouseController {
    @Autowired
    WarehouseService warService;

    //库存集合
    @RequestMapping("/war-list")
    @ResponseBody
    public List<Warehouse> warList(){
        List<Warehouse> warehouses = warService.selectWarehouse();
        return warehouses;
    }

    @PostMapping("/save-warehouses")
    @ResponseBody
    public void saveWarehouses(@RequestBody Warehouse warehouse){
       warService.saveWarehouse(warehouse);
    }
    @PostMapping("/delete-warehouses")
    @ResponseBody
    public void deleteWarehouses(@RequestParam(value = "warId") Integer warId){
        warService.deleteWarehouse(warId);
    }
}
